﻿using ZFramework.Runtime;
using ProcedureOwner = ZFramework.Runtime.Fsm<ZFramework.Runtime.IProcedureManager>;
namespace ZGame
{
    public class ProcedureInitResource : ProcedureBase
    {
        private bool _initResourceSuccess = false;
        public override void OnEnter(ProcedureOwner gameWorldOwner)
        {
            base.OnEnter(gameWorldOwner);
            Log.Error("开始  GameWorldInitResource  初始化资源");
            AOTGameEntry.resourceManager.InitResource(InitResourceCompleted);
        }

        void InitResourceCompleted()
        {
            _initResourceSuccess = true;
        }

        public override void OnUpdate(ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
        {
            base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
            if (_initResourceSuccess)
            {
                ChangeState<ProcedureSplash>(procedureOwner);
            }
        }
    }
}